<?php
namespace view;

class HTMLBlogView {
    private $applicationModel;


    /**
    * __constructor
    */
    public function __construct()     {
        $this->applicationModel = new \model\ApplicationModel();
    }


    /**
    * @param string $blogResult
	* @param string \model\BlogModel $blogModel
	* @return string HTML
    *
    * return -> hämtar och visar blogginlägg listat på Första sidan
    */
    public function returnBlogsInHTML($blogResult,\model\CommentModel $commentModel ) {
        $HTMLblogs = "";

        while($row = mysql_fetch_array($blogResult)) {
            $HTMLblogs .="	<div class='blogginlagg'>
            					<div class='blogginlagg_rubrik'>$row[1]</div>
	                                <p>$row[2]</p>
	                                <div class='blogginlagg_creat'>Created by: $row[4]</div>
	                                <div class='blogginlagg_datum'>Date created: $row[3]</div>
	                                <div class='blogglank'>
									<a href='?".$this->applicationModel->m_showBlogCommentsURL
									."=$row[0]'>Show comments (".$commentModel->returnNumberOfComments($row[0]).") </a>
	                                <a href='?".$this->applicationModel->m_addCommentURL."=$row[0]'>Add comment </a>
	                                <a href='?".$this->applicationModel->m_deleteBlogPostURL."=$row[0]'>Remove post </a>
	                                <a href='?".$this->applicationModel->m_editBlogPostURL."=$row[0]'>Edit post </a>
                                </div>
                            </div>";
        }

        return $HTMLblogs;
    }


    /**
    * @param string $blogHeader
	* @param string $blogText
	* @return string HTML
    *
    * return -> visar medelar om att ny blogpost är registrerad skapad
    */
    public function returnSuccessfulBlogPostPage($blogHeader, $blogText) {
        return "
		         <div id='newblogpost'><h2>New Blog post registred Successful</h2>
		                <h2>New blogpost</h2>
		                <h3>$blogHeader</h3>
		                <p>$blogText</p>
		         </div>";
    }


	/**
    * @return string HTML
    *
    * return -> visar medelar om att blogpost är updaterad ändrad
    */
    public function returnSuccessfulUpdateBlogPostPage() {
        return "<h2>Blogpost updated Successfully!</h2>";
    }


  	/**
    * @return string HTML
    *
    * return -> visar medelar om att blogposten är borttagen
    */
    public function returnRemovedBlogPost() {
        return "<h2>Blogpost Successfully removed</h2>";
    }


    /**
	* @return string HTML
    *
    * return -> visar text "typ felmedelande"
	*/
	public function returnNotYourBlogPost() {
        return "<h2>You cant remove/edit someone elses post!</h2>";
    }


}

